package com.tinyseed.emcp.api.exception.bean;

import com.tinyseed.emcp.api.basicdata.domain.convert.DTOConvert;
import com.tinyseed.emcp.api.exception.entity.ExceptionInfo;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.sql.Timestamp;

/**
 * ExceptionInfo
 *
 * @author tinyCode
 * @date 2019-12-13 14:47:18
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ExceptionInfoOutputDTO implements Serializable {

    /**
     * 唯一主键
     */
    private Long id;

    /**
     * 异常描述
     */
    private String description;

    /**
     * 异常类型
     */
    private String eventType;

    /**
     * 企业名称
     */
    private String enterpriseName;

    /**
     * 组织名称
     */
    private String organizeName;

    /**
     * 处理状态
     */
    private String currentStatus;

    /**
     * 处理状态code
     */
    private String currentStatusCode;

    /**
     * 企业名称
     */
    private Long enterpriseId;

    /**
     * 监测点名称
     */
    private String monitorName;

    /**
     * 组织机构id
     */
    private String organizeId;

    /**
     * 监测点id
     */
    private Long monitorId;

    /**
     * 监测点地址
     */
    private String instrumentAddress;

    /**
     * 监测点类型
     */
    private String equipmentType;

    /**
     * 异常备注，具体到某个设备异常
     */
    private String remark;

    /**
     * 创建时间
     */
    private Timestamp createTime;

    /**
     * 最后修改时间
     */
    private Timestamp modifyTime;

    /**
     * 创建人
     */
    private String creator;

    /**
     * 最后操作人
     */
    private String modifier;

    public ExceptionInfo convertToExceptionInfo() {
        ExceptionInfoOutputDTOConvert convert = new ExceptionInfoOutputDTOConvert();
        ExceptionInfo result = convert.convert(this);
        return result;
    }

    private static class ExceptionInfoOutputDTOConvert implements DTOConvert<ExceptionInfoOutputDTO, ExceptionInfo> {

        @Override
        public ExceptionInfo convert(ExceptionInfoOutputDTO exceptioninfoOutputDTO) {
            ExceptionInfo exceptioninfo = new ExceptionInfo();
            BeanUtils.copyProperties(exceptioninfoOutputDTO, exceptioninfo);
            return exceptioninfo;
        }
    }

}
